// pages/hz_information/hz_infornation.js
var api = require('../../utils/api.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    jbxx: true,
    jbjl: false,
    jcjl: false,
    yyjl: false,
    ssjl: false,
    zyjl: false,
    tbsx: false,
    srys: false,
    apipath: api.Apipath,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var userId = options.id
    if (wx.getStorageSync('userid')) {
      wx.request({
        url: api.Arch,
        data: { userId: userId },
        method: 'Post',
        success: function (res) {
          that.setData({ arch: res.data.data })
        },
      })
      wx.request({
        url: api.Disease,
        data: { userId: userId },
        method: 'Get',
        success: function (res) {
          that.setData({ disease: res.data.data })
        },
      })
      wx.request({
        url: api.Operation,
        data: { userId: userId },
        method: 'Get',
        success: function (res) {
          that.setData({ operation: res.data.data })
        },
      })
      wx.request({
        url: api.Inspect,
        data: { userId: userId },
        method: 'Get',
        success: function (res) {
          that.setData({ inspect: res.data.data })
        },
      })
      wx.request({
        url: api.Medica,
        data: { userId: userId },
        method: 'Get',
        success: function (res) {
          that.setData({ medica: res.data.data })
        },
      })
      wx.request({
        url: api.Hospital,
        data: { userId: userId },
        method: 'Get',
        success: function (res) {
          that.setData({ hospital: res.data.data })
        },
      })
      wx.request({
        url: api.Prvdoctors,
        data: { userId: userId },
        method: 'Get',
        success: function (res) {
          that.setData({ prvdoctors: res.data.data })
        },
      })
      wx.request({
        url: api.Remind,
        data: { userId: userId },
        method: 'Get',
        success: function (res) {
          that.setData({ remind: res.data.data })
        },
      })
    } else {
      wx.navigateTo({
        url: '/pages/signin/signin',
      })
    }
  },
  jbxx: function () {
    //基本信息
    var that = this;
    that.setData({ jbxx: true, jbjl: false, jcjl: false, yyjl: false, ssjl: false, zyjl: false, tbsx: false, srys: false })
  },
  jbjl: function () {
    //疾病记录
    var that = this;
    that.setData({ jbxx: false, jbjl: true, jcjl: false, yyjl: false, ssjl: false, zyjl: false, tbsx: false, srys: false })
    if (wx.getStorageSync('userid')) {
      wx.request({
        url: api.Disease,
        data: { userId: wx.getStorageSync('userid') },
        method: 'Get',
        success: function (res) {
          that.setData({ disease: res.data.data })
        },
      })
    }
  },
  jcjl: function () {
    //检查记录
    var that = this;
    that.setData({ jbxx: false, jbjl: false, jcjl: true, yyjl: false, ssjl: false, zyjl: false, tbsx: false, srys: false })
    if (wx.getStorageSync('userid')) {
      wx.request({
        url: api.Inspect,
        data: { userId: wx.getStorageSync('userid') },
        method: 'Get',
        success: function (res) {
          that.setData({ inspect: res.data.data })
        },
      })
    }
  },
  yyjl: function () {
    //用药记录
    var that = this;
    that.setData({ jbxx: false, jbjl: false, jcjl: false, yyjl: true, ssjl: false, zyjl: false, tbsx: false, srys: false })
    if (wx.getStorageSync('userid')) {
      wx.request({
        url: api.Medica,
        data: { userId: wx.getStorageSync('userid') },
        method: 'Get',
        success: function (res) {
          that.setData({ medica: res.data.data })
        },
      })
    }
  },
  ssjl: function () {
    //手术记录
    var that = this;
    that.setData({ jbxx: false, jbjl: false, jcjl: false, yyjl: false, ssjl: true, zyjl: false, tbsx: false, srys: false })
    if (wx.getStorageSync('userid')) {
      wx.request({
        url: api.Operation,
        data: { userId: wx.getStorageSync('userid') },
        method: 'Get',
        success: function (res) {
          that.setData({ operation: res.data.data })
        },
      })
    }
  },
  zyjl: function () {
    //住院记录
    var that = this;
    that.setData({ jbxx: false, jbjl: false, jcjl: false, yyjl: false, ssjl: false, zyjl: true, tbsx: false, srys: false })
    if (wx.getStorageSync('userid')) {
      wx.request({
        url: api.Hospital,
        data: { userId: wx.getStorageSync('userid') },
        method: 'Get',
        success: function (res) {
          that.setData({ hospital: res.data.data })
        },
      })
    }
  },
  tbsx: function () {
    //特别事项
    var that = this;
    that.setData({ jbxx: false, jbjl: false, jcjl: false, yyjl: false, ssjl: false, zyjl: false, tbsx: true, srys: false })
    if (wx.getStorageSync('userid')) {
      wx.request({
        url: api.Remind,
        data: { userId: wx.getStorageSync('userid') },
        method: 'Get',
        success: function (res) {
          that.setData({ remind: res.data.data })
        },
      })
    }
  },
  srys: function () {
    // 私人医生
    var that = this;
    that.setData({ jbxx: false, jbjl: false, jcjl: false, yyjl: false, ssjl: false, zyjl: false, tbsx: false, srys: true })
    if (wx.getStorageSync('userid')) {
      wx.request({
        url: api.Prvdoctors,
        data: { userId: wx.getStorageSync('userid') },
        method: 'Get',
        success: function (res) {
          that.setData({ prvdoctors: res.data.data })
        },
      })
    }
  },
  lookmore: function () {
    /*健康档案 */
    wx.navigateTo({
      url: '/pages/edit_hzda/edit_hzda',
    })
  },

  lookmorezhuyuan: function () {
    /*住院记录编辑页 */
    wx.navigateTo({
      url: '/pages/fb/fb',
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})